package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 套餐菜品数据层
 */
@Mapper
public interface SetMealDishMapper {

    /**
     * 通过菜品ID获取相应的套餐
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish where dish_id = #{id}")
    List<SetmealDish> selectSetMealByDishId(Long id);

    /**
     * 新增套餐菜品
     * @param setmealDishList
     */
    @AutoFill(OperationType.INSERT)
    void addSetMealDish(List<SetmealDish> setmealDishList);

    /**
     * 通过套餐ID获取当前套餐的全部菜品
     * @param setMealId
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{setMealId}")
    List<SetmealDish> selectSetMealDishById(Long setMealId);

    /**
     * 通过套餐ID删除套餐菜品信息
     * @param setMealId
     */
    @Delete("delete from setmeal_dish where setmeal_id = #{setMealId}")
    void deleteSetMealDishByMealId(Long setMealId);
}
